<template>
    <div class="box" v-loading="isLoading">
        <ul>
            <li v-for="item in newsList" :key="item.id" class="news">
                <div class="left" v-loading="isLoading">
                    <div class="title">{{ item.title }}</div>
                    <div class="info">
                        <span>{{ item.source }}</span>
                        <span>{{ item.time }}</span>
                    </div>
                </div>
                <div class="right" v-loading="isLoading">
                    <img :src="item.img" alt="img" />
                </div>
            </li>
        </ul>
    </div>

</template>

<script setup>
import { ref } from 'vue';
import axios from 'axios'
let newsList = ref([]);
Func()
async function Func() {
    let OBJ = await axios.get('http://localhost:4000/api/news')
    newsList.value = OBJ.data.data
}
console.log(newsList)
</script>

<style scoped>
.loading:before {
    z-index: 999;
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: #fff url('./IMG/01.gif') no-repeat center;
    background-size: auto;
}

.box {
    position: relative;
    width: 800px;
    min-height: 600px;
    margin: 10px auto;
    border-radius: 5px;
}

.news {
    display: flex;
    margin: 0 auto;
    padding: 20px 0;
    cursor: pointer;
}

.news .left {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding-right: 10px;
}

.news .left .title {
    font-size: 20px;
}

.news .left .info {
    color: #999999;
}

.news .left .info span {
    margin-right: 20px;
}

.news .right {
    width: 160px;
    height: 120px;
}

.news .right img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
</style>